//
//  RotateView.m
//  FindGift
//
//  Created by dllo on 15/11/19.
//  Copyright © 2015年 DHF. All rights reserved.
//

#define WIDTH ([UIScreen mainScreen].bounds.size.width)
#define HEIGHT ([UIScreen mainScreen].bounds.size.height)

#import "RotateView.h"

@implementation RotateView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
    }
    return self;
}


- (void)createSubviews
{
    if (self.myArray.count != 0) {
        NSString *str1 = ((InforRotateModel *)[self.myArray objectAtIndex:0]).img;
        NSString *str2 = ((InforRotateModel *)[self.myArray objectAtIndex:1]).img;
        NSString *str3 = ((InforRotateModel *)[self.myArray objectAtIndex:2]).img;
        NSString *str4 = ((InforRotateModel *)[self.myArray objectAtIndex:3]).img;
        //    NSString *str5 = ((Rotate *)[self.myArray objectAtIndex:4]).image_url;
        
        NSArray *imagesURLStrings = @[str1,str2,str3,str4];
        
        
//        CGFloat w = self.bounds.size.width;
        
        
        //网络加载 --- 创建带标题的图片轮播器
        SDCycleScrollView *cycleScrollView2 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, WIDTH, 200 * HEIGHT / 667) imageURLStringsGroup:nil]; // 模拟网络延时情景
        cycleScrollView2.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
        cycleScrollView2.delegate = self;
        cycleScrollView2.dotColor = [UIColor yellowColor]; // 自定义分页控件小圆标颜色
        //    cycleScrollView2.placeholderImage = [UIImage imageNamed:@"placeholder"];
        [self addSubview:cycleScrollView2];
        
        //             --- 模拟加载延迟
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            cycleScrollView2.imageURLStringsGroup = imagesURLStrings;
        });
        
        
        // 清除缓存
        [cycleScrollView2 clearCache];
    }
    
}



#pragma mark - SDCycleScrollViewDelegate

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"---点击了第%ld张图片", index);
//    [self.rotateDelegate nextController:index];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
